package com.itheima.guanbing1;

import java.util.concurrent.ArrayBlockingQueue;

public class Foodie implements  Runnable{
    private ArrayBlockingQueue<String> queue;
    public Foodie(ArrayBlockingQueue<String> queue) {
        this.queue=queue;
    }
    @Override
    public void run() {
        while (true) {
            //从保温箱里拿
            String take = null;
            try {
                Thread.sleep(1000);
                take = queue.take();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"拿了一个"+take);
        }
    }
}
